import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test9 {
    public static void main(String[] args) {
        int[] numbers={0,1,1,0,0};
        boolean a=IsContinuous(numbers);
        System.out.println(a);
    }
    public static boolean IsContinuous (int[] numbers) {
        // write code here
        Arrays.sort(numbers);

        // 计算 0 的个数
        int sum = 0;
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i] == 0) {
                sum++;
            } else {
                break;
            }
        }

        // num 用来记录，连续的数字的个数
        int num = 0;
        // 用来记录差值
        int k = 0;
        int l = 0;
        for (int i = sum; i < numbers.length - 1; i++) {
            if (numbers[i + 1] - numbers[i] == 1) {
                num++;
            } else {
                if (numbers[i + 1] - numbers[i] == 2) {
                    l++;
                }
                k += numbers[i + 1] - numbers[i];
            }
        }
        if (num + 1 == numbers.length - sum) {
            return true;
        } else {
            if (l == sum) {
                return true;
            }
            if (k - 1 != sum) {
                return false;
            }
            return true;
        }

    }






    public static void main02(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n=in.nextInt();
            int k=num(n);
            System.out.println(k);
        }
    }

    public static int num(int n){
        if(n==1){
            return 1;
        }else if(n == 2){
            return 2;
        }else{
            return num(n-1)+num(n-2);
        }
    }





    public static void main01(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            Stack<Integer> stack = new Stack<>();
            int num = 0;
            while (a != 0) {
                int b = a % 10;
                stack.add(b);
                a /= 10;
                num++;
            }
            int b = num / 3;
            int c = num % 3;
            if (b != 0) {
                while (c != 0) {
                    System.out.print(stack.pop());
                    c--;
                    if (c == 0) {
                        System.out.print(",");
                    }

                }

                while (!stack.isEmpty()) {
                    int count = 3;
                    while (count != 0) {
                        System.out.print(stack.pop());
                        count--;
                    }
                    if (!stack.isEmpty()) {
                        System.out.print(",");
                    }

                }
            } else {
                while (c != 0) {
                    System.out.print(stack.pop());
                    c--;

                }
            }

        }
    }
}